//
//  LoginViewController.m
//  Nidalee
//
//  Created by 李康 on 2020/12/1.
//  Copyright © 2020 李康. All rights reserved.
//

#import "LoginViewController.h"
#import "RegistViewController.h"

@interface LoginViewController () <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *usernameTF;
@property (weak, nonatomic) IBOutlet UITextField *passwordTF;

@property (weak, nonatomic) IBOutlet UIButton *loginBtn;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"登录"];
    [self addRightTextBarButtonByItemTitle:@"注册"];
    [self addLeftImgBarButtonByItemImg:@"loginBack"];
    self.usernameTF.delegate = self;
    self.passwordTF.delegate = self;
    [self.usernameTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    [self.passwordTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    
    self.loginBtn.layer.cornerRadius = 6;
    self.loginBtn.enabled = NO;
}

-(void)textFieldDidChange:(UITextField *)textField{

    if(!IsStrEmpty(self.usernameTF.text) && !IsStrEmpty(self.passwordTF.text)){
        [self.loginBtn setBackgroundColor:HexColor(0x5086FC)];
        self.loginBtn.enabled = YES;
    }else{
        [self.loginBtn setBackgroundColor:HexColor(0xCCCCCC)];
        self.loginBtn.enabled = NO;
    }
}


-(void)rightBarAction:(id)sender{
    RegistViewController *reVc = [[RegistViewController alloc]init];
    [self.navigationController pushViewController:reVc animated:YES];
}


- (IBAction)xieyiClick:(id)sender {
    
}

- (IBAction)yinsiClick:(id)sender {
    
}

- (IBAction)loginClick:(id)sender {
    [self popViewController];
}

@end
